from flask import Flask, make_response, request

from parse import parse_excel

app = Flask(__name__)


# 解析xml文件 这里需要传入文件
@app.route('/parse_xml', methods=['POST'])
def parse_xml():
    data = request.get_json()
    parse_id = data.get('parse_id')
    parse_url = data.get('parse_url')
    if not parse_id or not parse_url:
        return make_response(dict(code=403, msg='参数不完整'))
    try:
        return parse_excel.parse(parse_id, parse_url)
    except Exception as e:
        print(e)
        return make_response(dict(code=500, msg='解析出错'))


if __name__ == '__main__':
    app.run(host='0.0.0.0')
